package com.ate.javamvp.mvp.model;

import com.ate.javamvp.api.Api;
import com.ate.bean.GoodsBean;
import com.ate.bean.SearchBean;
import com.ate.bean.TuijianBean;
import com.ate.javamvp.mvp.contract.Contract;
import com.ate.lib_core.http.factory.RetrofitFactory;
import com.ate.lib_core.http.factory.RetrofitType;
import com.google.gson.JsonObject;

;import io.reactivex.Observable;
import okhttp3.RequestBody;

/**
 * @author Ate
 * @description:
 * @date :2020/12/16 13:25
 */
public class DataModel implements Contract.DataXiaModel {

    @Override
    public Observable<TuijianBean> getTuijian() {
        return RetrofitFactory.getInstance()
                .createRetrofit(RetrofitType.NETWORK)
                .getRetrofit().create(Api.class).getTuijian();
    }

    @Override
    public Observable<GoodsBean> getGoods(){
        return RetrofitFactory.getInstance()
                .createRetrofit(RetrofitType.NETWORK)
                .getRetrofit().create(Api.class).getGoods();
    }

    @Override
    public Observable<SearchBean> getSearch(String keyword , String type) {
        return RetrofitFactory.getInstance().createRetrofit(RetrofitType.NETWORK)
                .getRetrofit().create(Api.class).getSearchGoods(keyword,type,"1","999");
    }

    @Override
    public Observable<JsonObject> login(RequestBody requestBody) {
        return RetrofitFactory.getInstance().createRetrofit(RetrofitType.NETWORK)
                .getRetrofit().create(Api.class).login(requestBody);
    }


    @Override
    public void destory() {

    }
}
